<?php get_header(); ?>
<?php include 'sidebar-left.php'; ?>
<section class="content_wrapp">
	<div class="menu">
		<?php
			wp_nav_menu(array('theme_location' => 'red-menu', 'container' => false, 'menu_class' => 'red'));
		?>
	</div>
	<div class="main-slider">	
		<div class="slider-wrapper">
			<div id="slider" class="nivoSlider"><?php
				$args = array(
					'orderby'		=>	'date',
					'order'			=>	'DESC',
					'post_type'		=>	'post',
					'post_status'	=>	'publish',
					'meta_key'		=>	'display_in_slider',
					'meta_value'	=>	'on',
				);
				$posts_array = get_posts( $args );
				foreach ($posts_array as $post){
					if ( has_post_thumbnail($post->ID)) {
						echo get_the_post_thumbnail($post->ID, 'slider-size',
							array('class' => 'slider-image', 'title' => '#slide-'.$post->ID, 'alt' => $post->post_title)
						);
					}
				}
				wp_reset_query();
				?>
			</div>
			<div id="slider-text">
				<?php 
				$posts_array = get_posts( $args );
				foreach ($posts_array as $post){
					if ( has_post_thumbnail($post->ID)) { ?>
						<div id="slide-<?php echo $post->ID; ?>">
							<h2 class="slider-title">
								<a href="<?php echo get_permalink($post->ID) ?>"><?php echo $post->post_title; ?></a>
							</h2>
							<p class="slider-short-desc">
								<?php get_substr($post->post_content, 14); ?>
							</p>
						</div>
				<?php }
				}
				wp_reset_query();
				?>
			</div>
		</div>		
	</div>
	<div class="news">
		<h2 class="single-title"><?php echo get_option($shortname.'_homepage_cats_title'); ?></h2>
		<?php 
			$i = 1;
			if(get_option($shortname.'_homepage_exclude_cats')){
				query_posts($query_string.'page=ID&posts_per_page='.(int)get_option($shortname.'_number_post').'&category__not_in='.get_option($shortname.'_homepage_exclude_cats'));
			} else {
				query_posts($query_string.'page=ID&posts_per_page='.(int)get_option($shortname.'_number_post'));
			}
			global $paged;
			if (have_posts()) : while (have_posts()) : the_post(); ?>
				<article class="news_state no_border">					
					<p>
						<?php if ( has_post_thumbnail() ) {
							echo '<a class="state_image" href="<?php the_permalink(); ?>" title="news">';
							the_post_thumbnail('thumb-size-1',
								array('title' => get_the_title())
							);
							echo '</a>';
						}?>
						<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
						<?php get_substr(get_the_content(), 14); ?>
					</p>
					<a class="coments" href="<?php the_permalink(); ?>#comments" title="<?php _e('Comments', $themename); ?>">• <?php _e('Comments'); ?> (<?php comments_number(0, 1, '%') ?>)</a>
					<a class="read_more" href=<?php the_permalink(); ?>" title="<?php _e('Read more'); ?>">• <?php _e('Read more...', $themename); ?></a>
				</article>
				<?php if(!is_int($i/2)): ?><div class="border"></div><?php endif; ?>
				<?php $i++; ?>
		<?php endwhile; ?>
		<?php wpt_pagenavi(); ?>
		<?php endif; ?>
	</div>
	<div>
	<?php
		$posts_array = get_posts('post_type=page&p='.(int)get_option($shortname.'_homepage_content'));
		foreach ($posts_array as $post){
			echo '<h2 class="single-title">'.$post->post_title.'</h2>';
			echo $post->post_content;
		}
	?>
	</div>
</section>
<?php include 'sidebar-right.php'; ?>
<?php get_footer() ?>